Jinja is a template engine for the Python programming language. It is similar to the Django template engine but provides Python-like expressions while ensuring that the templates are evaluated in a sandbox. It's a text-based template language and thus can be used to generate any markup as well as sourcecode. It's licensed under a BSD License.
The Jinja template engine allows customization of tags[1], filters, tests, and globals[2]. Also, unlike the Django template engine, Jinja allows the template designer to call functions with arguments on objects.
Jinja, like Smarty, also ships with an easy-to-use filter system similar to the Unix pipeline.
Here is a small example of a template:
from jinja import from_string tmpl = from_string(u'''\ <html> <head><title>{{ variable|escape }}</title></head> <body> {% for item in item_list %} {{ item }}{% if not loop.last %},{% endif %} {% endfor %} </body> </html>''') print tmpl.render( variable='Value with <unsafe> data', item_list=[1, 2, 3, 4, 5, 6] )